/*
 * Created: 2022-09-12 15:10:17
 * Author : 涛涛涛
 */

import React, { FC } from 'react';
import { View, Text } from '@tarojs/components';
import { styled } from 'linaria/react';
import { useClassName } from '@/utils/index';
import Taro, { useRouter } from '@tarojs/taro';
export interface IProps extends ICompProps {}
HeadNavRightButtons.defaultProps = {} as Partial<IProps>;
function HeadNavRightButtons(props: IProps) {
    const { className, style } = props;
    const localClassName = useClassName('HeadNavRightButtons', className);
    const handleClickSearch = () => {
        Taro.navigateTo({
            url: 'pages/HomeSearch/HomeSearch',
        });
    };
    const handleClickMenu = () => {
        Taro.redirectTo({
            url: 'pages/Mine/Mine',
        });
    };
    // const route = useRouter();
    // const gotoHome = () => {
    //     // 如果已经在首页,则什么也不做
    //     if (route.path.includes('/pages/Home/Home')) return;
    //     // 跳转到首页
    //     Taro.redirectTo({
    //         url: 'pages/Home/Home',
    //     });
    // };
    return (
        <RootView className={localClassName} style={style}>
            <View className="search icon-wrap">
                <Text className="iconfont" onClick={handleClickSearch}>
                    &#xe62b;
                </Text>
            </View>
            <View className="menu icon-wrap">
                <Text className="iconfont" onClick={handleClickMenu}>
                    &#xe790;
                </Text>
            </View>
        </RootView>
    );
}
export default React.memo(HeadNavRightButtons as FC<IProps>);
const RootView = styled(View)`
    &.HeadNavRightButtons {
        margin-left: auto;
        width: fit-content;
        height: 100%;
        display: flex;
        align-items: center;
        .icon-wrap {
            margin: -20px;
            > .iconfont {
                padding: 20px;
            }
        }
        .search > .iconfont {
            font-size: 50px;
            line-height: 1;
        }
        .menu {
            margin-left: 50px;
            > .iconfont {
                font-size: 48px;
                line-height: 1;
            }
        }
    }
`;
